<template>
  <div>
    <XmolBox title="指标数据参考">
      <div class="flex p10 w-100">
        <div class="flex1">
          <p class="mb10 col-orange1">入参</p>
          <pre style="font-size: 0.1rem" class="col-white2">
            {
              "projectId": "2",
              "dataType": "MONTH",
              "indexIds": [ "2013", "2014" ],
              "scope": 0,
              "startDate": "2021-02-01",
              "endDate": "2022-01-07"
            }
          </pre>
        </div>
        <div class="flex1">
          <p class="mb10 col-orange1">data返回数据</p>
          <pre style="font-size: 0.1rem" class="col-white2">
            [{
              "dt": "2021-02-01",
              "indexId": 2013,
              "indexName": "自繁仔猪成本",
              "projectId": 2,
              "value": "211.0"
            },……]
          </pre>
        </div>
      </div>
    </XmolBox>
    <section class="content mt10">
      <div>
        <p class="tt">dealLinesData（柱状图、折线图适用）</p>
        <p><span class="td">方法名：</span> Common.dealLinesData(data)</p>
        <p><span class="td">参数<el-tag size="mini" class="ml5" type="info">data</el-tag> ：</span>通用指标接口返回的data数据</p>
        <p><span class="td">返回数据：</span>{ seriesData, xAxis} （具体格式参考如下）</p>
        <pre style="font-size: 0.1rem" class="col-white2">
          参考：
          {
            "xAxis": [ "2021-08-01", "2021-09-01", "2021-10-01", "2021-11-01", "2021-12-01" ],
            "seriesData": [
              { "name": "母猪存栏", "indexId": "1", "data": [ "4120.0", "4850.0", "4720.0", "4420.0", "4490.0" ] },
              { "name": "仔猪存栏", "indexId": "2", "data": [ "2260.0", "3230.0", "2650.0", "2740.0", "4120.0" ] },
              { "name": "肥猪存栏", "indexId": "3", "data": [ "2530.0", "4630.0", "3420.0", "4020.0", "4360.0" ] }
            ]
          }
        </pre>
      </div>

      <div>
        <p class="tt">dealPieData（饼图、漏斗图适用）</p>
        <p><span class="td">方法名：</span> Common.dealPieData(data)</p>
        <p><span class="td">参数<el-tag size="mini" class="ml5" type="info">data</el-tag> ：</span>通用指标接口返回的data数据</p>
        <p><span class="td">返回数据：</span>[{name: '', value: '', indexId: ' }, …… ] （具体格式参考如下）</p>
        <pre style="font-size: 0.1rem" class="col-white2">
          参考：
          [
            { "name": "仔猪", "indexId": "1", "value": "2740.0" },
            { "name": "肥猪", "indexId": "2", "value": "4020.0" },
            { "name": "母猪存栏", "indexId": "3", "value": "4490.0" },
            { "name": "仔猪存栏", "indexId": "4", "value": "4120.0" },
            { "name": "肥猪存栏", "indexId": "5", "value": "4360.0" }
          ]
        </pre>
      </div>
    </section>
  </div>
</template>

<script>
export default {
  data () {
    return {
      // 数据
      dealData: []
    };
  },
  mounted () {
  },
  methods: {
    getSeriesData () {
      let res = {'status': {'code': 200, 'msg': '服务请求成功'}, 'data': [{'projectId': 2, 'dt': '2021-08-01', 'indexId': 1, 'indexName': '母猪存栏', 'value': '4120.0'}, {'projectId': 2, 'dt': '2021-08-01', 'indexId': 2, 'indexName': '仔猪存栏', 'value': '2260.0'}, {'projectId': 2, 'dt': '2021-08-01', 'indexId': 3, 'indexName': '肥猪存栏', 'value': '2530.0'}, {'projectId': 2, 'dt': '2021-09-01', 'indexId': 1, 'indexName': '母猪存栏', 'value': '4850.0'}, {'projectId': 2, 'dt': '2021-09-01', 'indexId': 2, 'indexName': '仔猪存栏', 'value': '3230.0'}, {'projectId': 2, 'dt': '2021-09-01', 'indexId': 3, 'indexName': '肥猪存栏', 'value': '4630.0'}, {'projectId': 2, 'dt': '2021-10-01', 'indexId': 1, 'indexName': '母猪存栏', 'value': '4720.0'}, {'projectId': 2, 'dt': '2021-10-01', 'indexId': 2, 'indexName': '仔猪存栏', 'value': '2650.0'}, {'projectId': 2, 'dt': '2021-10-01', 'indexId': 3, 'indexName': '肥猪存栏', 'value': '3420.0'}, {'projectId': 2, 'dt': '2021-11-01', 'indexId': 1, 'indexName': '母猪存栏', 'value': '4420.0'}, {'projectId': 2, 'dt': '2021-11-01', 'indexId': 2, 'indexName': '仔猪存栏', 'value': '2740.0'}, {'projectId': 2, 'dt': '2021-11-01', 'indexId': 3, 'indexName': '肥猪存栏', 'value': '4020.0'}, {'projectId': 2, 'dt': '2021-12-01', 'indexId': 1, 'indexName': '母猪存栏', 'value': '4490.0'}, {'projectId': 2, 'dt': '2021-12-01', 'indexId': 2, 'indexName': '仔猪存栏', 'value': '4120.0'}, {'projectId': 2, 'dt': '2021-12-01', 'indexId': 3, 'indexName': '肥猪存栏', 'value': '4360.0'}]};
      this.dealData = this.Common.dealLinesData(res.data || []);
    }
  }
};
</script>
